import './index.scss';
import '@/assets/styles/index.scss';
import { Router, Switch, Route } from 'react-router-dom';
import React from 'react';
import { Provider } from 'react-redux';
import store from './store';
import history from './utils/history';
import Loading from '@/pages/Loading';
// const Search = React.lazy(() => import('@/pages/Search'));
import Search from '@/pages/Search/index';
import ProfileEdit from './pages/Profile/Edit';
import Chat from './pages/Profile/Chat';
import Test from './test练习文件';
import AuthRoute from './components/AuthRoute';
import SearchResult from './pages/Search/Result';
import Article from './pages/Article';
// 路由懒加载
// 作用：提升加载速度，不然会加载全部的组件
const Layout = React.lazy(() => import('@/pages/Layout'));
const Login = React.lazy(() => import('@/pages/Login'));
export default function App() {
  return (
    <Provider store={store}>
      <Router history={history}>
        <React.Suspense fallback={<Loading></Loading>}>
          <Switch>
            <Route path="/login" component={Login}></Route>
            <Route path="/search" component={Search} exact></Route>
            <Route path="/article/:id" component={Article} />
            <Route path="/search/result" component={SearchResult} exact></Route>
            {/* <AuthRoute path="/profile/edit" component={ProfileEdit}></AuthRoute> */}
            {/* ...restprops */}
            <AuthRoute path="/profil" component={ProfileEdit}></AuthRoute>
            <AuthRoute path="/profil/edit" component={ProfileEdit}></AuthRoute>
            <AuthRoute path="/profile/chat" component={Chat}></AuthRoute>
            <Route path="/test" component={Test}></Route>
            <Route path="/" component={Layout}></Route>
          </Switch>
        </React.Suspense>
      </Router>
    </Provider>
  );
}

//
